#include<stdio.h>
#include<stdlib.h>

struct node
{
	int val;
	struct node *next;
}*new;

struct node *first=NULL;

print()
{
	struct node *p;
	for(p=first;p!=NULL;p=p->next)
{
	printf(" %d ",p->val);
}
}


append()
{
	struct node *new=malloc(sizeof(struct node));
	printf("enter a number");
	scanf("%d",&new->val);
	
	new->next=first;
	first=new;

	print();  
}

count()
{
	struct node *p;
	int c,countnum=0;
	printf("enter the number whose occurence is to checked");
	scanf("%d",&c);
	for(p=first;p!=NULL;p=p->next)
{
	if(p->val==c)
	{
		countnum++;
	}
}
	printf("occurence is %d times\n",countnum);
}

main()
{
	int a;
	
     for(;;)
{
      	printf("enter the operation on linked list\n");
	printf("1.Append\n");
	printf("2.Count\n");
        printf("3.Exit\n");
		
      scanf("%d",&a);            
     switch(a)
      {
               case(1):
                       append();
                       break;
		case(2):
			count();
			break;
   	       case(3):
			exit(0);
	}
}
return 0;
}


		
